﻿using agsXMPP.protocol.iq.roster;

namespace VSTalk.Engine.Core.XmppConnection.RosterObserver
{
    public static class RosterData
    {
        public static bool Subscribed(RosterItem item)
        {
            return item.Subscription == SubscriptionType.both ||
                   item.Subscription == SubscriptionType.to;
        }

        public static string Name(RosterItem item)
        {
            if (!string.IsNullOrEmpty(item.Name))
            {
                return item.Name;
            }
            if (!string.IsNullOrEmpty(item.Jid.User))
            {
                return item.Jid.User;
            }
            if (!string.IsNullOrEmpty(item.Jid.Server))
            {
                return item.Jid.Server;
            }
            return "unknown";
        }
    }
}